using System;

namespace Atomic.Libraries.Jobs
{
	/// <summary>
	/// Represents one line in the job.status file.
	/// </summary>
	[Serializable]
	internal sealed class JobStatusEntry
	{
		private JobStatus status;
		private string summary;
		[NonSerialized] private string id;
		[NonSerialized] private DateTime? startTime, endTime;
		[NonSerialized] private JobState state;

		public JobStatusEntry(JobStatus status, string summary)
		{
			this.status = status;
			this.summary = summary;

			id = null;
			state = JobState.Waiting;
		}

		public void Save()
		{
			status.Save(this);
		}

		public string Id
		{
			get
			{
				return id;
			}
			set
			{
				id = value;
			}
		}

		public DateTime? StartTime
		{
			get
			{
				return startTime;
			}
			set
			{
				startTime = value;
			}
		}

		public DateTime? EndTime
		{
			get
			{
				return endTime;
			}
			set
			{
				endTime = value;
			}
		}

		public JobState State
		{
			get
			{
				return state;
			}
			set
			{
				state = value;
			}
		}

		public string Summary
		{
			get
			{
				return summary;
			}
		}
	}
}
